package cn.hniu.service.Impl;

import cn.hniu.mapper.UsersMapper;
import cn.hniu.pojo.Users;
import cn.hniu.service.UsersService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UsersServiceImpl implements UsersService {

    @Autowired
    private UsersMapper usersMapper;

    @Override
    public IPage findUserInformation(Integer begin, Integer size) {
        IPage page=new Page(begin,size);
        usersMapper.selectPage(page,null);
        return page;
    }

    @Override
    public List<Users> findUserByCondition(String name, Integer begin, Integer size) {
        return usersMapper.findUserByCondition(name,begin,size);
    }

    @Override
    public Integer addUser(Users users) {
        return usersMapper.insert(users);
    }

    @Override
    public Integer updateUser(Users users) {
        return usersMapper.updateById(users);
    }

    @Override
    public Integer deleteUser(Integer id) {
        return usersMapper.deleteById(id);
    }

}
